#include <iostream>
using namespace std;
const int N = 110;
int a[N][N];

#include <iostream>
using namespace std;
const int N = 110;
int a[N][N];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (i == 0 || j == 0 || i == (n - 1) || j == m - 1)
			{
				cout << a[i][j] << " ";
			}
			else
			{
				int t = int(((a[i - 1][j] + a[i + 1][j] + a[i][j + 1] + a[i][j - 1] + a[i][j]) / 5.0) + 0.5);
				cout << t << " ";
			}
		}
		cout << endl;
	}


	return 0;
}
